<template>
    <div>
        <el-table :data="noticeList"
                  @cell-click="toNoticeDetail">
            <el-table-column
                    prop="title"
                    label="公告名称">
            </el-table-column>
            <el-table-column
                    prop="typeString"
                    label="公告类型"
                    width="120px">
            </el-table-column>
            <el-table-column
                    prop="time"
                    label="发布时间"
                    width="120px">
            </el-table-column>
        </el-table>

        <div class="page">
            <el-pagination
                    background
                    :page-size="pageSize"
                    :page-count="totalPage"
                    :current-page="pageIndex"
                    layout="prev, pager, next"
                    :total="totalRecord">
            </el-pagination>
        </div>
    </div>
</template>

<script>
    import util from 'assets/js/util.js'

    export default {
        data() {
            return {
                noticeList: [],
                totalRecord: 0,
                totalPage: 0,
                pageIndex: 0,
                pageSize: 0,
                caseId: 0,
                creditorId: 0
            }
        },
        methods: {
            toNoticeDetail: function (row, column, cell, event) {
                window.location.href = '../notice/notice-detail.html?' + 'id=' + row.id;
            },
        },
        mounted() {

            const _self = this;

            util.ajax({
                url: `/notice/list`,
                params: {page: 0, size: 10},
                success: function (data) {
                    data.data.content.forEach(_message => _self.noticeList.push({
                        time: util.formatDate(_message.sureTime),
                        sureTime: _message.sureTime,
                        title:_message.title,
                        id: _message.id,
                        type: _message.type,
                        typeString: _message.typeString,

                    }));
                    _self.totalRecord = data.data.totalRecord;
                    _self.currentPage = data.data.currentPage;
                    _self.pageSize = data.data.pageSize;
                    _self.totalPage = data.data.totalPage;
                    _self.pageIndex = data.data.pageIndex;
                },
            });
        },
    }
</script>

<style scoped>
    .el-table th > .cell {
        text-align: center;
    }

    button {
        font-size: 18px;
    }

    el-button {
        position: absolute;
    }

    .notice-list {
        margin: 50px 8px;
        line-height: 20px;
    }

    .time {
        float: right;
        margin-right: 25px;
    }

    .page {
        text-align: center;
        position: fixed;
        bottom: 10%;
        left: 0;
        right: 0;
        width: 100%;
    }

</style>
